package our.pack;

import java.util.ArrayList;


import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

/*
 * Deze class wordt gebruikt om plaatjes aan te maken die op de kaart (googlemaps/mapView) 
 * te gezien kan worden
 */

public class GpsTrackerItemizedOverlay extends ItemizedOverlay<OverlayItem>{

	private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
	Context mContext;
	
	public GpsTrackerItemizedOverlay(Drawable defaultMarker) {
		super(boundCenterBottom(defaultMarker));
		// TODO Auto-generated constructor stub
	}
	
	public GpsTrackerItemizedOverlay(Drawable defaultMarker, Context context) {
		super(boundCenterBottom(defaultMarker));
		mContext = context;
	}
		
		

	public void addOverlay(OverlayItem overlay)
	{
		mOverlays.add(overlay);
		populate();
		
	}
	
	
	
	public void clear(){
		mOverlays.clear();
	}
	public void changeOverlay(int index, Drawable drawable){
		mOverlays.get(index).setMarker(drawable);
	}
	
	
	@Override
	protected OverlayItem createItem(int i) {
		return mOverlays.get(i);
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return mOverlays.size();
	}
	
	@Override
	protected boolean onTap(int index)
	{
		OverlayItem item = mOverlays.get(index);
		AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
		dialog.setTitle(item.getTitle());
		dialog.setMessage(item.getSnippet());
		//dialog.show();
		return true;
		
	}

}
